﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
    <title>compile()方法应用示例</title>
</head>
<body>
    <script>
        let str = "Every man in the world! Every woman on earth!";
        let patt = /man/g;
        let str2 = str.replace(patt, "person");
        document.write(str2 + "<br>");
        patt = /(wo)?man/g;
        patt.compile(patt);
        str2 = str.replace(patt, "person");
        document.write(str2);
    </script>
</body>
</html>